package ru.susu.algebra.jtex;

import ru.susu.algebra.util.StringUtilities;

/**
 * @author akargapolov
 * @since: 16.08.2010
 */
public class TexBeginEndElement extends TexElementBase
{
	private String _elementCode;

	private TexBeginEndElement(String elementCode)
	{
		_elementCode = elementCode;
	}

	@Override
	public String generateContent()
	{
		StringBuffer buffer = new StringBuffer();
		buffer.append("\\begin{" + _elementCode + "}");

		buffer.append(StringUtilities.NEW_LINE);

		buffer.append(generateSubItemsContent());

		buffer.append(StringUtilities.NEW_LINE);

		buffer.append("\\end{" + _elementCode + "}");
		buffer.append(StringUtilities.NEW_LINE);
		return buffer.toString();
	}

	public TexBeginEndElement setWithoutNumber()
	{
		if (!_elementCode.contains("*"))
		{
			_elementCode = _elementCode + "*";
		}
		return this;
	}

	public static final String DOCUMENT = "document";

	public static TexBeginEndElement document()
	{
		return new TexBeginEndElement(DOCUMENT);
	}

	private static final String THEOREM = "theorem";

	public static TexBeginEndElement threorem()
	{
		return new TexBeginEndElement(THEOREM);
	}

	private static final String LEMMA = "lemma";

	public static TexBeginEndElement lemma()
	{
		return new TexBeginEndElement(LEMMA);
	}

	public static final String DEFINITION = "definition";

	public static TexBeginEndElement definition()
	{
		return new TexBeginEndElement(DEFINITION);
	}

	public static final String NOTATION = "notation";

	public static TexBeginEndElement notation()
	{
		return new TexBeginEndElement(NOTATION);
	}

	public static final String REMARK = "remark";

	public static TexBeginEndElement remark()
	{
		return new TexBeginEndElement(NOTATION);
	}

	private static final String PROOF = "proof";

	public static TexBeginEndElement proof()
	{
		return new TexBeginEndElement(PROOF);
	}

	private static final String ALIGN = "align";

	public static TexBeginEndElement align()
	{
		return new TexBeginEndElement(ALIGN);
	}

	private static final String ALIGNED = "aligned";

	public static TexBeginEndElement aligned()
	{
		return new TexBeginEndElement(ALIGNED);
	}

	private static final String GATHER = "gather";

	public static TexBeginEndElement gather()
	{
		return new TexBeginEndElement(GATHER);
	}

	public static final String THEBIBLIOGRAPHY = "thebibliography";

	public static TexBeginEndElement thebibliography()
	{
		return new TexBeginEndElement(THEBIBLIOGRAPHY);
	}

	private static final String PMATRIX = "pmatrix";

	public static TexBeginEndElement pmatrix()
	{
		return new TexBeginEndElement(PMATRIX);
	}

	private static final String ENUMERATE = "enumerate";

	public static TexBeginEndElement enumerate()
	{
		return new TexBeginEndElement(ENUMERATE);
	}

	private static final String EQUATION = "equation";

	public static TexBeginEndElement equation()
	{
		return new TexBeginEndElement(EQUATION);
	}
}
